﻿using System.Collections.Generic;

namespace ValidationFramework.Web.MVC.JQueryClientScriptProviders
{
	public class JQueryRequiredStringProvider : IClientScriptProvider
	{
		#region IClientScriptProvider Members

		public string GetFunctionName(Rule rule)
		{
			return "requiredStringEx";
		}

		public List<object> GetFunctionArguments(Rule rule)
		{
			var requredStringRule = (RequiredStringRule)rule;
			var args = new List<object>
				{
					requredStringRule.TrimWhiteSpace, 
					requredStringRule.IgnoreCase.GetValueOrDefault(), 
				};

			if (requredStringRule.HasInitialValue)
				args.Add(requredStringRule.InitialValue);
			else
				args.Add("");

			return args;
		}

		#endregion
	}
}
